package com.x.ant.service;

import com.x.ant.dao.AreaDao;
import com.x.ant.model.City;
import com.x.ant.model.District;
import com.x.ant.model.Province;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AreaService extends BaseService {
    @Autowired
    private AreaDao areaDao;

    public List<Province> selectProvinceList(Province province) {
        try {
            return areaDao.selectProvinceList(province);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public List<City> selectCityList(City city) {
        try {
            return areaDao.selectCitytList(city);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public List<District> selectDistrictList(District district) {
        try {
            return areaDao.selectDistrictList(district);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }
}
